package com.exp06.Listener;

import jakarta.servlet.Servlet;
import jakarta.servlet.ServletRequestEvent;
import jakarta.servlet.ServletRequestListener;
import jakarta.servlet.http.HttpServletRequest;

public class MyRequestListener implements ServletRequestListener {
    private int count = 0;

    public void requestInitialized(ServletRequestEvent sre) {
        HttpServletRequest request = (HttpServletRequest) sre.getServletRequest();
//        System.out.println(request.getRequestURI());
        if (request.getRequestURI().equals("/exp06/onlineCount.jsp")) {
            count++;
            sre.getServletContext().setAttribute("count", count);
        }
    }

    public void requestDestroyed(ServletRequestEvent sre) {

    }
}
